<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link href="{ADMIN_THEME}images/reset.css" rel="stylesheet" type="text/css" />
	<link href="{ADMIN_THEME}images/system.css" rel="stylesheet" type="text/css" />
	<link href="{ADMIN_THEME}images/dialog.css" rel="stylesheet" type="text/css" />
	<link href="{ADMIN_THEME}images/switchbox.css" rel="stylesheet" type="text/css" />
	<link href="{ADMIN_THEME}luos/css/style.min.css?v=4.1.0" rel="stylesheet"><link href="{ADMIN_THEME}images/table_form.css" rel="stylesheet" type="text/css" />
	{template admin/top.html}
	<script type="text/javascript" src="{ADMIN_THEME}js/jquery.min.js"></script>
	<script type="text/javascript" src="{ADMIN_THEME}js/dialog.js"></script>
	<script type="text/javascript">
		var sitepath = '{SITE_PATH}{ENTRY_SCRIPT_NAME}';
		var finecms_admin_document = "{$cats[$data['catid']]['setting']['document']}";
	</script>
	<script type="text/javascript" src="{LANG_PATH}lang.js"></script>
	<script type="text/javascript" src="{ADMIN_THEME}js/core.js"></script>
	<title>admin</title>
</head>
<body style="font-weight: normal;">
<div class="subnav">
	<div class="content-menu ib-a blue line-x">
		<a href="{if $backurl}{$backurl}{else}{url('admin/content/', array('modelid'=>$modelid, 'catid'=>$catid))}{/if}" onclick="clz()"><em>{lang('a-con-42')}</em></a><span>|</span>
		<a href="javascript:;" class="on"><em>{lang('a-con-24')}</em></a>
	</div>
	<div class="bk10"></div>
	<div class="table-responsive mytable">
		<form method="post" action="{url('admin/goods/add')}" id="myform" name="myform">
			<input name="backurl" type="hidden" value="{$backurl}" />
			<table class="table table-striped" width="100%">
				<tbody>
				{if $verify}
				<tr>
					<th width="130">{lang('a-mod-137')}：</th>
					<td><a href="{url('admin/content/editverify', array('id'=>$data['id']))}">{lang('a-mod-140')}</a></td>
				</tr>
				{/if}
				<tr>
					<th width="130"><font color="red">*</font>&nbsp;{lang('a-con-29')}：</th>
					<td>
						<select name="data[category]" id="category">
							{loop $category $key=>$value}
								<option value="{$value[id]}">{$value[name]}</option>
							{/loop}
						</select>
					</td>
				</tr>
				<tr>
					<th><font color="red">*</font>&nbsp;名称：</th>
					<td><input type="text" class="input-text" size="80" id="title" value="{$data['name']}" name="data[name]" onBlur="ajaxtitle()" required />
						<div class="onShow" id="title_text"></div></td>
				</tr>
				<tr>
					<th><font color="red">*</font>&nbsp;价格：</th>
					<td><input type="text" class="input-text" size="15" id="price" value="{$data['price']}" name="data[price]" onBlur="ajaxtitle()" required />
						<div class="onShow" id="price_text"></div></td>
				</tr>
				<tr>
					<th>关键字：</th>
					<td><input type="text" class="input-text" size="50" id="keywords" value="{$data['keywords']}" name="data[keywords]" />
						<div class="onShow">{lang('a-con-44')}</div></td>
				</tr>
				<tr id="banner">
					<th>banner上传：</th>
					<td>
						<input type="text" class="input-text" size="50" value="{$data['thumb']}" name="data[thumb]" id="thumb" />
						<input type="button" style="width:66px;cursor:pointer;" class="btn btn-success btn-sm" onClick="preview('thumb')" value="{lang('a-mod-118')}" />
						<input type="button" style="width:66px;cursor:pointer;" class="btn btn-success btn-sm" onClick="uploadImage('thumb', '{$SITE_THUMB_WIDTH}', '{$SITE_THUMB_HEIGHT}')" value="{lang('a-mod-119')}" />
						<div class="onShow">{lang('a-pic')}</div>
					</td>
				</tr>
				<tr>
					<th>简述：</th>
					<td><textarea style="width:490px;height:66px;" id="description" name="data[description]" />{$data['description']}</textarea></td>
				</tr>
				{$data_fields}
				<!--<tr>
					<th>商品详情上传：</th>
					<td><input type="text" class="input-text" size="50" value="{$data['thumb']}" name="data[thumb]" id="thumb" />
						<input type="button" style="width:66px;cursor:pointer;" class="btn btn-success btn-sm" onClick="preview('thumb')" value="{lang('a-mod-118')}" />
						<input type="button" style="width:66px;cursor:pointer;" class="btn btn-success btn-sm" onClick="uploadImage('thumb', '{$SITE_THUMB_WIDTH}', '{$SITE_THUMB_HEIGHT}')" value="{lang('a-mod-119')}" />
						<div class="onShow">{lang('a-pic')}</div></td>
				</tr>-->
				<tr>
					<th>库存：</th>
					<td><input type="text" class="input-text" size="15" value="{$data['stock']}" name="data[stock]" /></td>
				</tr>
				<tr>
					<th>销量：</th>
					<td><input type="text" class="input-text" size="15" value="{$data['buy']}" name="data[buy]" /></td>
				</tr>
				<tr>
					<th>货源：</th>
					<td><input type="text" class="input-text" size="15" value="{$data['source']}" name="data[source]" /></td>
				</tr>
				<tr>
					<th>热卖：</th>
					<td><input type="text" class="input-text" size="15" value="{$data['hot']}" name="data[hot]" /></td>
				</tr>
				<tr>
					<th>上/下架：</th>
					<td>
						上架：<input type="checkbox" value="{$data['status']}" name="data[status]" {if $data['status']}checked{/if}>&nbsp;&nbsp;&nbsp;
						下架：<input type="checkbox" value="{$data['status']}" name="data[status]" {if $data['status'] == 0}checked{/if}>&nbsp;&nbsp;&nbsp;
					</td>
				</tr>
				<tr>
					<th>&nbsp;</th>
					<td><input type="submit" class="btn btn-success btn-sm" value="{lang('a-submit')}" name="submit" onClick="$('#load').show()" />
						<span id="load" style="display:none"><img src="{ADMIN_THEME}images/loading.gif"></span>
					</td>
				</tr>
				</tbody>
			</table>
		</form>
	</div>
</div>
<script type="text/javascript">
	$(function(){
		window.top.art.dialog({id:'clz'}).close();
		var catid = $("#catid").val();
		var cats = new Array();
		{loop $cats $t}
		{if $t['modelid']==$modelid}
		cats[{$t['catid']}]="{$t['setting']['document']}";
		{/if}
		{/loop}
		finecms_admin_document = cats[catid];
		$("#catid").change(function(){
			var catid = $(this).val();
			finecms_admin_document = cats[catid];
		});
	});
	function clz() {
		window.top.art.dialog({ id:'clz',title:'Loading',fixed:true,lock:false,content: '<img src="{ADMIN_THEME}images/onLoad.gif">' });
	}
	function ajaxtitle() {
		$('#title_text').html('');
		get_kw();
		$.post(sitepath+'?s=admin&c=content&a=ajaxtitle&id='+Math.random(), { title:$('#title').val(), id:{php echo $data[id] ? $data[id] : 0;} }, function(data){

			if (data == '0' || data == 0) {
				$("#title_text").addClass("onCorrect");
				$("#title_text").removeClass("onError");
				$("#title_text").html("&nbsp;");
			} else {
				$('#title_text').html(data);
				$("#title_text").removeClass("onCorrect");
				$("#title_text").addClass("onError");
			}
		});
	}
	function loadInfo() {
		var url   = '{url("admin/content/ajaxloadinfo/")}&kw='+$("#keywords").val();
		var winid = 'loadinfo';
		window.top.art.dialog(
				{id:winid, okVal:fc_lang[6], cancelVal:fc_lang[7], iframe:url, title:'{lang('a-con-50')}', width:'660', height:'280', lock:true},
				function(){
					var d     = window.top.art.dialog({id:winid}).data.iframe;
					var ids   = d.document.getElementById('select').value;
					var arrid = ids.split(',');
					var c     = '';
					for (var i in arrid) {
						var id = arrid[i];
						if (id) {
							var title = d.document.getElementById('title_'+id).value;
							c += '<li id="rel_'+id+'">·<span>'+title+'</span><a onclick="remove_relation(\'rel_'+id+'\', \''+id+'\')" class="close" href="javascript:;"></a></li>';
						}
					}
					$("#relation_text").append(c);
					var rids = $("#relation").val();
					$("#relation").val(rids+ids);
				},
				function(){
					window.top.art.dialog({id:winid}).close();
				}
		);
		void(0);
	}
	//移除相关文章
	function remove_relation(sid, id) {
		var relation_ids = $('#relation').val();
		if(relation_ids !='' ) {
			$('#'+sid).remove();
			var r_arr = relation_ids.split(',');
			var newrelation_ids = '';
			$.each(r_arr, function(i, n){
				if(n!=id) {
					if(i==0) {
						newrelation_ids = n;
					} else {
						newrelation_ids = newrelation_ids+','+n;
					}
				}
			});
			$('#relation').val(newrelation_ids);
		}
	}


</script>
</body>
</html>
